<!-- 仪表盘 -->
<template>
  <div class="item-info">
    <div class="title">
      <span>{{ itemData.name }}</span>
      <div v-if="!itemData.isFault" class="title-right">
        <ElectricityQuantity :data="dataValue" :is-online="itemData.isFault"/>
        <Battery :data="dataValue1" :is-online="itemData.isFault"/>
      </div>
      <div v-else class="title-right-fault">
        <i/>故障
      </div>
    </div>
    <div :id="itemData.echartsName" class="echarts"/>
    <ul>
      <li class="position"><i :style="{backgroundImage:'url(' + firePumpHouse + ')'}"/>{{ itemData.place }}</li>
      <li class="firePumpHouse"><i :style="{backgroundImage:'url(' + position + ')'}"/>{{ itemData.address }}</li>
      <li class="time"><i :style="{backgroundImage:'url(' + time + ')'}"/>{{ itemData.date }}</li>
    </ul>
  </div>
</template>
<script>
import firePumpHouse from '@/assets/internetData/firePumpHouse.png'
import position from '@/assets/internetData/position.png'
import time from '@/assets/internetData/time.png'
import ElectricityQuantity from '@/components/ElectricityQuantity'
import Battery from '@/components/Battery'
import echarts from 'echarts'
export default {
  components: {
    ElectricityQuantity,
    Battery
  },
  props: {
    itemData: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      firePumpHouse,
      position,
      time,
      dataValue: 1, // 信号值0-5
      dataValue1: 100// 电池百分比
    }
  },
  computed: {
  },
  created() {
    this.$nextTick(function() {
      var dashboard = echarts.init(document.getElementById(this.itemData.echartsName))
      const that = this
      dashboard.setOption({
        tooltip: {
          formatter: '{c}' + that.itemData.echartsCompany
        },
        series: [
          {
            name: '',
            type: 'gauge',
            min: '0',
            max: that.itemData.echartsMax,
            radius: '100%',
            axisLine: {
              show: true,
              lineStyle: {
                color: that.itemData.echartsColorList,
                width: 10
              }
            },
            splitLine: {
              show: true,
              length: 20,
              lineStyle: {
                color: '#ccc',
                width: 3
              }
            },
            axisTick: {
              show: true,
              splitNumber: 5
            },
            axisLabel: {
              show: true,
              formatter: function(v) {
                return v.toFixed(0)
              }
            },
            title: {
              show: false
            },
            detail: {
              show: true,
              fontWeight: 900,
              fontSize: 14,
              formatter: function(value) {
                return value + ' ' + that.itemData.echartsCompany
              }
            },
            data: that.itemData.echartsData
          }
        ]
      })
    })
  },
  methods: {
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.item-info{
  width: 260px;
  display: inline-block;
  box-sizing: border-box;
  box-shadow:0px 0px 5px 3px rgba(243,243,243,1);
  border: 1px solid rgba(243,243,243,1);
  margin: 0 10px;
  margin-top: 50px;
  border-radius:5px;
  .title{
    width: 100%;
    height: 40px;
    font-size: 14px;
    padding: 10px 15px;
    box-sizing: border-box;
    span{
      float: left;
      font-size: 14px;
      font-weight: bold;
    }
    .title-right{
      float: right;
      color: #69A139;
      height: 20px;
    }
    .title-right-fault{
      float: right;
      color: #69A139;
      i{
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        margin-right: 5px;
        background-color: #EC0C0C;
      }
    }
  }
  .echarts{
    width: 100%;
    height: 200px;
  }
  >ul{
    background:rgba(249,249,249,1);
    overflow: hidden;
    padding: 10px 15px;
    box-sizing: border-box;
    li{
      height: 40px;
      line-height: 40px;
      color: #3D4241;
      font-size: 13px;
      position: relative;
      height: 40px;
      line-height: 40px;
      color: #373131;
      position: relative;
      padding-left: 24px;
      font-size: 14px;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
      i{
        position: absolute;
        display: block;
        background-size: 100%;
        color: #36B4F7;
        background-repeat: no-repeat;
      }
    }
    .time i{
      width:11px;
      height:11px;
      left: 2px;
      top: 14px;
    }
    .position i{
      width:12px;
      height:18px;
      left: 2px;
      top: 14px;
    }
    .firePumpHouse i{
      width:13px;
      height:15px;
      left: 1px;
      top: 12px;
    }
  }
}
</style>
